class EfDateFormatter extends EfFieldFormatter

Provides formatting methods for date, datetime and datestamp field types.

Methods

__construct(EntityMetadataWrapper $property, bool $isMultivalue)

Constructor.

array|string
value()

Returns the current field item as a raw array.

array
values()

Returns all raw field items in an array.

all()

Returns an array of all field items as EfFieldFormatter objects.

array
setDelta($delta)

Set the current field delta.

bool
isDeltaValid(null $delta = NULL)

Checks if the given or current field delta exists.

bool
notEmpty()

Shortcut for the possible not so easy to understand isDeltaValid() method.

bool
isAccessible()

Check if current user is allowed to view this field.

getIterator()

Implementing IteratorAggregate interface.

int
count()

Implementing Countable interface.

$this
setFormat(string $format)

Set the date format name which will be used for printing the date.

$this
setCustomFormat(string $format)

Set a custom PHP date format string which will be used for printing the date.

bool
hasEnddate()

Checks if an enddate is specified for the current date field item.

int
date()

Returns a timestamp for current date field item.

int
enddate()

Returns a timestamp of the enddate for current date field item.

string
duration(int $granularity = 2)

Return the duration from start to enddate as a string using format_interval.

string
formatted($useEnddate = FALSE)

Returns a date formatted which the given or currently set date format.

mixed
customFormatted($useEnddate = FALSE)

Returns a date formatted which the given or currently set PHP date format string.

__toString()

No description

Details

in EfFieldFormatter at line 23
__construct(EntityMetadataWrapper $property, bool $isMultivalue)

Constructor.

Parameters

EntityMetadataWrapper $property The value of this field wrapped by an EntityMetadataWrapper.
bool $isMultivalue Whether this field has a cardinality greater than one.

in EfFieldFormatter at line 43
array|string value()

Returns the current field item as a raw array.

Return Value

array|string

in EfFieldFormatter at line 52
array values()

Returns all raw field items in an array.

Return Value

array

in EfFieldFormatter at line 61
EfFieldFormatter[] all()

Returns an array of all field items as EfFieldFormatter objects.

Return Value

EfFieldFormatter[]

in EfFieldFormatter at line 74
array setDelta($delta)

Set the current field delta.

Parameters

$delta

Return Value

array

in EfFieldFormatter at line 91
bool isDeltaValid(null $delta = NULL)

Checks if the given or current field delta exists.

Parameters

null $delta

Return Value

bool

in EfFieldFormatter at line 102
bool notEmpty()

Shortcut for the possible not so easy to understand isDeltaValid() method.

Return Value

bool

in EfFieldFormatter at line 113
bool isAccessible()

Check if current user is allowed to view this field.

Can be needed if a module like field_permissions is in use.

Return Value

bool True, if current user is allowed to view this field.

in EfFieldFormatter at line 124
EfFieldFormatterIterator getIterator()

Implementing IteratorAggregate interface.

If we wrap a list, we return an iterator over the data list.

in EfFieldFormatter at line 133
int count()

Implementing Countable interface.

Return Value

int The number of items of this field.

at line 792
$this setFormat(string $format)

Set the date format name which will be used for printing the date.

Parameters

string $format A Drupal date format name

Return Value

$this

at line 803
$this setCustomFormat(string $format)

Set a custom PHP date format string which will be used for printing the date.

Parameters

string $format A PHP date format string.

Return Value

$this

at line 813
bool hasEnddate()

Checks if an enddate is specified for the current date field item.

Return Value

bool

at line 828
int date()

Returns a timestamp for current date field item.

Return Value

int

at line 848
int enddate()

Returns a timestamp of the enddate for current date field item.

Return Value

int

at line 865
string duration(int $granularity = 2)

Return the duration from start to enddate as a string using format_interval.

Parameters

int $granularity

Return Value

string

at line 879
string formatted($useEnddate = FALSE)

Returns a date formatted which the given or currently set date format.

Parameters

$useEnddate

Return Value

string

at line 896
mixed customFormatted($useEnddate = FALSE)

Returns a date formatted which the given or currently set PHP date format string.

Parameters

$useEnddate

Return Value

mixed

at line 925
__toString()